package com.ssm.controller;


import com.ssm.model.Admin;
import com.ssm.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.jws.WebParam;

@Controller
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/ss")
    public String selectAdmin(Model model){
        Admin admin = adminService.selectAdminByUsername("20130213", "200299");
        model.addAttribute("admin", admin);
        return "admin";
    }

    @RequestMapping("/toadminlogin")   //跳转用户登陆页面
    public String toadminlogin()
    {

        return "admin_login";
    }

    @RequestMapping("/adminlogin")
    public String adminlogin(String username, String password)
    {
        Admin admin = adminService.selectAdminByUsername(username, password);
        if (admin != null)
        {
            return "redirect:/tobookmanage";
        }
        else
        {
            return "admin_login";
        }
    }
}
